package com.general.common.mail;

import java.util.ArrayList;
import java.util.List;

import com.general.common.mail.impl.JavaxMailServer;
import com.general.utils.base.StringUtil;

public class MailSend implements Runnable{
	
	private JavaxMailServer mailServer;
	private List<String[]> sendList = new ArrayList<String[]>();
	
	public MailSend( List<String[]> sendList){
		this.sendList = sendList;
	}
	@Override
	public void run() {
		for(String[] send : sendList){
			//发送邮件
			sendMail(send);			
			//线程调度
			Thread.yield();
		}
	}
	
	public void sendMail(String[] send){
		// 邮件设定
		if(send!=null && send.length==3 
				&& !StringUtil.isEmpty(send[0])
				&& !StringUtil.isEmpty(send[1])
				&& !StringUtil.isEmpty(send[2])){
			try {
				mailServer.sendMail(send[0].trim(), send[1], send[2]);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	public List<String[]> getSendList() {
		return sendList;
	}
	public void setSendList(List<String[]> sendList) {
		this.sendList = sendList;
	}
	public JavaxMailServer getMailServer() {
		return mailServer;
	}
	public void setMailServer(JavaxMailServer mailServer) {
		this.mailServer = mailServer;
	}	
	
	
}
